<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'basic';
$return=array();
/*******basic*******/
if($_RQ['op']=='basic'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		if(!$postdata['username'] || !$postdata['pass'] || !$postdata['mid'] || !$postdata['type']){
			exi('参数不能为空！','error');
		}
		$record = pdo_get('core_users',array('name'=>$postdata['username']),array('id','salt','password'));
		if(!check_password($postdata['pass'],$record['salt'],$record['pass'])){
			exi('SAAS账号不存在或密码错误！','error');
		}
		$check_sign=md5($postdata['username'].$postdata['pass'].$postdata['mid'].$postdata['type'].$postdata['num'].$postdata['timestamp'].$postdata['secret']);
		$postdata['check_sign']=$check_sign;
		$this->plugin_setting('basic',$postdata);
		exi('生成签名成功');
	}
	$return['item']=$this->plugin_setting('basic');
	$return['item']['timestamp']=time();
	$htmls=array(
		'type'=>'edit',
		'desc'=>'生成签名',
		'edit'=>array(
			array('type'=>'tip','title'=>'上次生成的签名：'.$return['item']['check_sign']),
			array('type'=>'string','title'=>'username','name'=>'username'),
			array('type'=>'string','title'=>'pass','name'=>'pass'),
			array('type'=>'string','title'=>'mid','name'=>'mid'),
			array('type'=>'string','title'=>'type','name'=>'type'),
			array('type'=>'string','title'=>'num','name'=>'num'),
			array('type'=>'string','title'=>'timestamp','name'=>'timestamp'),
			array('type'=>'copy','title'=>'secret','name'=>'secret'),
		),
	);
	$return['htmls']=$htmls;
	exi($return);
}
/*******basic*******/
/*******op*******/
